from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, ForeignKey
from sqlalchemy.orm import relation, backref
from sqlalchemy.types import Integer, Unicode

from fidoweb.model.meta import Base

class HomepageGalleryPicType(Base) :
	__tablename__ = 'homepageGalleryPicTypes'
	
	id = Column(Integer, primary_key = True)
	name = Column(Unicode(20))

	def __init__(self, name = '') :
		self.name = name


class HomepageGalleryPic(Base) :
	__tablename__ = 'homepageGalleryPics'
	
	id = Column(Integer, primary_key = True)
	title = Column(Unicode(20))
	url = Column(Unicode(100))
	type_id = Column(Integer, ForeignKey('homepageGalleryPicTypes.id'))

	type = relation(HomepageGalleryPicType, backref = backref('pics', order_by = id))
	
	def __init__(self, type, title = '', url = '') :
		self.type = type
		self.title = title
		self.url = url
